<template>
	<view class="content">
		<view class="item">
			<text class="uni-text">经度：</text>
			<text class="uni-text">{{ markerObj.gps ? markerObj.gps.longitude : '' }}</text>
		</view>
		<view class="item">
			<text class="uni-text">纬度：</text>
			<text class="uni-text">{{ markerObj.gps ? markerObj.gps.latitude : '' }}</text>
		</view>
		<button v-if="putStatus" type="warn" size="mini" @click="changepositioning">修改坐标</button>
		<view class="item">
			<text class="uni-text">海拔高度：</text>
			<text class="uni-text">{{ markerObj.gps ? markerObj.gps.altitude : '' }}</text>
		</view>
		<view class="item">
			<text class="uni-text">方位角：</text>
			<text class="uni-text">{{ markerObj.gps ? markerObj.gps.angle : '' }}</text>
		</view>
		<view class="item">
			<text class="uni-text">速度：</text>
			<text class="uni-text">{{ markerObj.gps ? markerObj.gps.speed : '' }}</text>
		</view>
		<view class="item">
			<text class="uni-text">地址：</text>
			<text class="uni-text">{{ markerObj.gps ? markerObj.gps.address : '' }}</text>
		</view>
		<view class="item">
			<text class="uni-text">采集时间：</text>
			<text class="uni-text">{{ markerObj.time || '' }}</text>
		</view>
		<view class="item">
			<text class="uni-text">备注：</text>
			<textarea v-if="putStatus" class="uni-textarea" name="" id="" cols="30" rows="10" v-model="markerObj.descr"></textarea>
			<text v-else class="uni-text">{{ markerObj.descr }}</text>
		</view>
		<view class="item">
			<text class="uni-text">蓝牙：</text>
			<uni-table border stripe emptyText="暂无更多数据">
				<uni-tr>
					<uni-th align="center" width="50">序号</uni-th>
					<uni-th align="center">MAC</uni-th>
					<uni-th align="center">信号值</uni-th>
				</uni-tr>
				<uni-tr v-for="(item, index) in markerObj.bluetooth" :key="index">
					<uni-td align="center">{{ index + 1 }}</uni-td>
					<uni-td align="center">{{ item.mac }}</uni-td>
					<uni-td align="center">{{ item.rssi }}</uni-td>
				</uni-tr>
			</uni-table>
		</view>
		<view class="item">
			<text class="uni-text">WIFI：</text>
			<uni-table border stripe emptyText="暂无更多数据">
				<uni-tr>
					<uni-th align="center" width="50">序号</uni-th>
					<uni-th align="center">MAC</uni-th>
					<uni-th align="center">SSID</uni-th>
					<uni-th align="center">信号值</uni-th>
				</uni-tr>
				<uni-tr v-for="(item, index) in markerObj.wifi" :key="index">
					<uni-td align="center">{{ index + 1 }}</uni-td>
					<uni-td align="center">{{ item.mac }}</uni-td>
					<uni-td align="center">{{ item.ssid }}</uni-td>
					<uni-td align="center">{{ item.rssi }}</uni-td>
				</uni-tr>
			</uni-table>
		</view>
		<view class="item">
			<text class="uni-text">基站：</text>
			<uni-table border stripe emptyText="暂无更多数据">
				<uni-tr>
					<uni-th align="center" width="50">序号</uni-th>
					<uni-th align="center">类型</uni-th>
					<uni-th align="center">MNC</uni-th>
					<uni-th align="center">MCC</uni-th>
					<uni-th align="center">CID</uni-th>
					<uni-th align="center">LAC</uni-th>
					<uni-th align="center">信号值</uni-th>
				</uni-tr>
				<uni-tr v-for="(item, index) in markerObj.cell" :key="index">
					<uni-td align="center">{{ index + 1 }}</uni-td>
					<uni-td align="center">{{ item.type == 0 ? '连接' : '附近' }}</uni-td>
					<uni-td align="center">{{ item.mnc }}</uni-td>
					<uni-td align="center">{{ item.mcc }}</uni-td>
					<uni-td align="center">{{ item.cid }}</uni-td>
					<uni-td align="center">{{ item.lac }}</uni-td>
					<uni-td align="center">{{ item.rssi }}</uni-td>
				</uni-tr>
			</uni-table>
		</view>
	</view>
</template>

<script>
import { getCurrentDate, getGEO_status } from '@/utils/index.js';
export default {
	data() {
		return {
			indexvalue: 0,
			markersData: [],
			markerObj: {},
			putStatus: false
		};
	},
	onNavigationBarButtonTap(e) {
		console.log(e, '点击的事件');
		if (e.index == 0) {
			this.changePut();
		} else if (e.index == 1) {
			this.putStatus = true;
		}
	},
	onLoad(e) {
		this.markersData = JSON.parse(e.obj);
		console.log(this.markersData, '所有标记点数据');
		this.indexvalue = e.indexval;
		this.changemarker();
	},
	onShow() {
		uni.$once('backInfo', (res) => {
			console.log('修改坐标接收的参数', res);
			this.markerObj.gps.latitude = res.latitude;
			this.markerObj.gps.longitude = res.longitude;
			this.markerObj.gps.address = res.address;
			this.markerObj.modifyFlag = 1;
		});
	},
	methods: {
		changePut() {
			this.markersData.points[this.indexvalue] = this.markerObj;
			this.$axios
				.put(`/utils/locationRecord?token=${uni.getStorageSync('token')}`, {
					tenantId: uni.getStorageSync('userinfo').tenantId,
					userId: uni.getStorageSync('userinfo').userId,
					data: [
						{
							recordId: this.markersData.recordId,
							name: this.markersData.name,
							points: this.markersData.points,
							createTime: this.markersData.createTime
						}
					]
				})
				.then(
					(res) => {
						console.log(res, '修改成功');
						uni.navigateBack(2);
					},
					(err) => {
						console.log(err, '修改失败');
					}
				);
		},

		// 修改坐标
		changepositioning() {
			uni.navigateTo({
				url: `/pages/index/choosemap?latitude=${this.markerObj.gps.latitude}&longitude=${this.markerObj.gps.longitude}&type=1`
			});
		},

		changemarker() {
			this.markerObj = this.markersData.points[this.indexvalue];
			console.log('查看的标点', this.markerObj);
		}
	}
};
</script>

<style lang="scss" scoped>
.content {
	.uni-textarea {
		// flex: 1;
		height: 200rpx;
		border-radius: 10rpx;
		border: 1rpx solid #333;
		padding: 0 10rpx;
	}
}
</style>
